﻿using System;
using System.Collections.Generic;
using WEB.Core.Controls;
using Ext.Net;
using WEB.Core.Util;
using log4net;
using WEB.BLL.Services;
using WEB.BLL.Entities;
using WEB.BLL;

namespace WEB.APP.Modules.List
{
    public partial class ReportProjectDetail  : BasePage
    {
        public ReportProjectDetail()
            : base(SCREENS.LISTPROJECT, false)
        {
        }

        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            if (!string.IsNullOrEmpty(Request["id"]))
            {
                LoadData(Convert.ToDecimal(Request["id"]));
            }
        }

        protected void LoadData(decimal Id)
        {
            var _ett = ProjectService.GetInstance().LoadPrimaryKeyEX(new ProjectEntity() { ProjectId = Id });
            if (_ett == null)
                return;
            dfId.Text += _ett.ProjectId.ToString();
            dfTitle.Text += _ett.ProjectName;
            dfDescription.Html = _ett.ProjectDesc.Replace("strong>","b>");
            dfClient.Text = string.Format("{0}<br />Email: {1}<br />Address: {2}", _ett.ClientName, _ett.Email, _ett.Addr1);

            IList<StudentEntity> _lst = StudentService.GetInstance().LoadByProject(new StudentEntity() { ProjectId = Id });
            if (_lst != null)
            {
                string _temp = "<table id=\"tbStudent\">\n";
                foreach (var item in _lst)
                {
                    _temp += string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>\n", item.StudentId, item.GivenName, item.SurName);
                }
                _temp += "</table>";
                dfStudent.Text = _temp;
            }
        }
    }
}